# -*- coding: utf-8 -*-
"""
Module Description:
Date: 2018/1/16
Author: FQ
"""


class DataCacheMixin(object):
    """
    临时数据缓存
    """
    def set_attr(self, field_name, value):
        setattr(self, field_name, value)

    def get_attr(self, field_name):
        return getattr(self, field_name, None)

    def apply_attr(self, field_name, add):
        value = getattr(self, field_name, 0)
        self.set_attr(field_name, value + add)
        return value + add
